package com.flexcloudsdk.prospectivesearch;
import java.util.logging.Logger;
import com.google.appengine.api.prospectivesearch.Subscription;
import com.google.appengine.api.prospectivesearch.Subscription.State;

public class CloudSubscription {
	private static final Logger log = Logger.getLogger(CloudSubscription.class.getName());
	private String sourceMethod;
	private String sourceClass;
	private Subscription subscription;
	
	public CloudSubscription() {
		log.info("CloudSubscription has been created by BlazeDS!");
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudSubscription.class.getName();
	}
	
	public String getErrorMessage() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return subscription.getErrorMessage();
	}
	
	public String getQuery() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return subscription.getQuery();
	}
	
	public void setSubscription(Subscription value) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		subscription = value;
	}
	
	public long getExpirationTime() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return subscription.getExpirationTime();
	}
	
	public State getState() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);
		return subscription.getState();
	}
	
}
